#ifndef IO_PORT_HPP
#define IO_PORT_HPP

#include <cstddef>

class Pin {
public:
    enum class Mode {
        Input,
        Output
    };

    enum class DriveType {
        PushPull,
        OpenDrain,
    };

    enum class PullType {
        None,
        PullUp,
        PullDown,
    };

    enum class Event : unsigned int {
        RisingEdge = 1,
        FallingEdge = 2,
        BothEdge = 3,
    };

public:
    virtual ~Pin() = default;
    virtual bool open(void) = 0;
    virtual bool close(void) = 0;
    virtual void set(bool status) = 0;
    virtual bool get(void) = 0;
    virtual void toggle(void) = 0;

    virtual bool setMode(Mode mode) = 0;
    virtual Mode getMode(void) = 0;
    virtual bool setDriveType(DriveType drive_type) = 0;
    virtual DriveType getDriveType(void) = 0;
    virtual bool setPullType(PullType pull_type) = 0;
    virtual PullType getPullType(void) = 0;

    virtual bool addEventCallback(Event event,void (*callback)(void)) = 0;
    virtual bool removeEventCallback(Event event) = 0;

    virtual int getErrorNumber(void) = 0;
};

class Port {
public:
    virtual ~Port() = default;
    virtual bool open(void) = 0;
    virtual bool close(void) = 0;
    virtual size_t read(void *buffer,size_t size) = 0;
    virtual size_t write(const void *buffer,size_t size) = 0;

    virtual Pin& getPin(int pin_number) = 0;

    virtual int getErrorNumber(void) = 0;
};

#endif
